/**
 * Created by wenquxing on 2016/5/19.
 */


var uuid = require('node-uuid'); //调用uuid模块
var usr=require('../dao/userDao');


function User(user){
    this.name=user.name;
    this.password=user.password;
}
module.exports = User;

User.prototype.save = function  save(callback) {
    var user = {
        name:this.name,
        password:this.password,
    };
    //创建一个connection
    connection.connect(function(err){
        if(err){
            console.log('[query] - :'+err);
            return callback(err);
        }
        console.log('[connection connect]  succeed!');
    });

    var  userAddSql = 'INSERT INTO t_user(id,name,password) VALUES(?,?,?)';
    var  userAddSql_Params = [,user.name,user.password];
    connection.query(userAddSql,userAddSql_Params,function (err, result) {
        if(err){
            connection.end();
            return callback(err);
        }

        console.log('--------------------------INSERT----------------------------');
        //console.log('INSERT ID:',result.insertId);
        console.log('INSERT ID:',result);
        console.log('-----------------------------------------------------------------');
    });
    connection.end();
}





